﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LiveSequence.Suite.Utils
{
  public class TextTNodeComparer : ITreeNodeComparer
  {
    private string _strText;

    #region ITreeNodeComparer Members
    /// <summary>
    /// Initializes a new instance of the <see cref="TextTNodeComparer"/> class.
    /// </summary>
    /// <param name="strText">The STR text.</param>
    public TextTNodeComparer(string strText)
    {
      if(string.IsNullOrEmpty(strText))
      {
        strText = string.Empty;
      }
      _strText = strText.ToLower();
    }

    /// <summary>
    /// Matches the specified t node.
    /// </summary>
    /// <param name="tNode">The t node.</param>
    /// <returns></returns>
    public bool Match(System.Windows.Forms.TreeNode tNode)
    {
      bool bResult = false;
      if(tNode != null)
      {
        string strNodeText = tNode.Text.ToLower();
        bResult = strNodeText.Contains(_strText);
      }
      return bResult;
    }

    #endregion
  }
}
